function pow(a1,a2)
%POW    Create plot of datasets and fits
%   POW(A1,A2)
%   Creates a plot, similar to the plot in the main curve fitting
%   window, using the data that you provide as input.  You can
%   apply this function to the same data you used with cftool
%   or with different data.  You may want to edit the function to
%   customize the code and this help message.
%
%   Number of datasets:  2
%   Number of fits:  1

 
% Data from dataset "a2 vs. a1":
%    X = a1:
%    Y = a2:
%    Unweighted
 
% Data from dataset "a2 vs. a1 (smooth)":
%    X = a1:
%    Y = a2:
%    Unweighted
%
% This function was automatically generated on 05-May-2007 20:56:05

% Set up figure to receive datasets and fits
f_ = clf;
figure(f_);
legh_ = []; legt_ = {};   % handles and text for legend
xlim_ = [Inf -Inf];       % limits of x axis
ax_ = subplot(1,1,1);
set(ax_,'Box','on');
axes(ax_); hold on;

 
% --- Plot data originally in dataset "a2 vs. a1"
a1 = a1(:);
a2 = a2(:);
h_ = line(a1,a2,'Parent',ax_,'Color',[0.333333 0 0.666667],...
     'LineStyle','none', 'LineWidth',1,...
     'Marker','.', 'MarkerSize',12);
xlim_(1) = min(xlim_(1),min(a1));
xlim_(2) = max(xlim_(2),max(a1));
legh_(end+1) = h_;
legt_{end+1} = 'a2 vs. a1';
 
% --- Plot data originally in dataset "a2 vs. a1 (smooth)"
sm_.y2 = smooth(a1,a2,0.25,'rloess',0);
h_ = line(a1,sm_.y2,'Parent',ax_,'Color',[0.333333 0.666667 0],...
     'LineStyle','none', 'LineWidth',1,...
     'Marker','.', 'MarkerSize',12);
xlim_(1) = min(xlim_(1),min(a1));
xlim_(2) = max(xlim_(2),max(a1));
legh_(end+1) = h_;
legt_{end+1} = 'a2 vs. a1 (smooth)';

% Nudge axis limits beyond data limits
if all(isfinite(xlim_))
   xlim_ = xlim_ + [-1 1] * 0.01 * diff(xlim_);
   set(ax_,'XLim',xlim_)
end


% --- Create fit "cf1"
st_ = [0.7527512701356 0.2810420845569 ];
ft_ = fittype('power1' );

% Fit this model using new data
cf_ = fit(a1,a2,ft_ ,'Startpoint',st_);

% Or use coefficients from the original fit:
if 0
   cv_ = {60.57476395947, -0.3575615348166};
   cf_ = cfit(ft_,cv_{:});
end

% Plot this fit
h_ = plot(cf_,'fit',0.95);
legend off;  % turn off legend from plot method call
set(h_(1),'Color',[1 0 0],...
     'LineStyle','-', 'LineWidth',2,...
     'Marker','none', 'MarkerSize',6);
legh_(end+1) = h_(1);
legt_{end+1} = 'cf1';

hold off;
legend(ax_,legh_, legt_);
